package cn.gov.msa.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import cn.gov.msa.dao.BaseShipMapper;
import cn.gov.msa.model.BaseShip;
import cn.gov.msa.service.BaseShipService;

public class BaseShipServiceImpl implements BaseShipService {
	
	@Autowired
	BaseShipMapper baseShipMapper;
	
	@Override
	public int deleteById(String shipid){
		return baseShipMapper.deleteByPrimaryKey(shipid);
		
	}

	@Transactional
	@Override
	public int insert(BaseShip record){
		int result = 0;
		if(baseShipMapper.updateByShipIDNumber(record) <= 0){
			result =  baseShipMapper.insert(record);
		}
		return result;
    }

	@Transactional
	@Override
	public int insertSelective(BaseShip record){
		int result = 0;
		if(baseShipMapper.updateByShipIDNumber(record) <= 0){
			result =  baseShipMapper.insertSelective(record);
		}
		return result;
    	
    }

	@Override
	public BaseShip selectById(String shipid){
		return baseShipMapper.selectByPrimaryKey(shipid);
    	
    }

	@Override
	public List<BaseShip> selectData(BaseShip ship) {
		return baseShipMapper.selectData(ship);
	}

	@Override
	public int update(BaseShip record){
		return baseShipMapper.updateByPrimaryKeySelective(record);
    	
    }

	@Override
	public int updateById(BaseShip record){
		return baseShipMapper.updateByPrimaryKey(record);
    	
    }

}
